package spring.superrun.record.mvc.service.impl;

import org.springframework.stereotype.Service;
import spring.superrun.record.mvc.dto.CompleteToken;
import spring.superrun.record.mvc.dto.TokenBody;
import spring.superrun.record.mvc.entity.SuperrunUserinfos;
import spring.superrun.record.mvc.service.JwtTokenService;
import spring.superrun.record.mvc.setup.CookieConfig;
import spring.superrun.record.mvc.setup.JWTConfig;
import spring.superrun.tool.newid.JwtUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Service("jwtTokenService")
public class JwtTokenServiceImpl implements JwtTokenService {
    @Override
    public CompleteToken CreateToken(@NotNull SuperrunUserinfos user) {
        CompleteToken token= new CompleteToken();
        token.setAccessToken(new TokenBody(JwtUtils.createToken(user.getId()
                ,JWTConfig.AccessToken)));
        token.setRefreshToken(new TokenBody(JwtUtils.createToken(user.getId()
                ,JWTConfig.RefreshToken)));
        return token;
    }

    @Override
    public TokenBody CreateAccessToken(@NotEmpty String refreshToken) {
        return null;
    }
}
